package com.qf.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.CustomerMapper;
import com.qf.pojo.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lixu
 */
@RestController
public class CustomerController {

    @Autowired
    private CustomerMapper customerMapper;

    @GetMapping("/sys/customer/table")
    public Map customersTable(){
        PageHelper.startPage(1,1);
        List<Customer> customerList = customerMapper.findList();
        PageInfo<Customer> pageInfo = new PageInfo<>(customerList);
        Map map = new HashMap<>();
        //LayUi返回的数据结构
        map.put("code",0);
        map.put("msg","成功");
        map.put("count",pageInfo.getTotal());
        map.put("data",pageInfo.getList());

        return map;
    }
}
